<!--
 * @Author: CHINAKAIYUAN<sunkaiyuan@namenode.cn>
 * @Date: 2022-02-03 14:41:20
 * @LastEditTime: 2023-10-19 12:19:15
 * @LastEditors: 孙开源 && sunkaiyuan@namenode.cn
 * @Description:   :gridOps="gridOptions" allocation
-->
<template>
  <sc-VxeTable ref="xGrid" :tablecode="'storage_action_deptallocation_detail'" :gridEvts="gridEvents"
    :url="api.storage.deptallocation.details">
  </sc-VxeTable>
  <SaveDialog v-if="dialog.save" ref="saveDialog" @success="handleSuccess" @closed="dialog.save = false"></SaveDialog>
  <car v-if="dialog.car" ref="carDialog" @success="handleSuccess" @closed="dialog.car = false">
  </car>
  <carry v-if="dialog.carry" ref="carryDialog" @success="handleSuccess" @closed="dialog.carry = false">
  </carry>
</template>
<script>
export default {
  name: "storage_action_deptallocation_details",
};
</script>
<script setup>
import { ref, nextTick } from "vue";
// , onMounted, reactive, ref
// const router = useRouter();
import SaveDialog from "./save";
import car from "./../../../comprehensive/car/car";
import carry from "./../../../comprehensive/carry/carry";
import api from "@/api";
const dialog = ref({
  save: false,
  car: false,
  carry: false
});

const xGrid = ref({});
const saveDialog = ref({});
const carDialog = ref({});
const carryDialog = ref({});
const handleSuccess = () => {
  xGrid.value.refresh();
};
const edit = (data) => {
  dialog.value.save = true;
  nextTick(() => {
    saveDialog.value.setData(data);
    saveDialog.value.open("edit");
  });
}
const gridEvents = {
  cellDblclick: function ({ row }) {
    edit(row.main)
    // gridEvents.editItem();
  },
  addItem: function () {
    dialog.value.save = true;
    nextTick(() => {
      saveDialog.value.open();
    });
  },
  addCar: function () {
    dialog.value.car = true;
    nextTick(() => {
      carDialog.value.open();
    });
  },
  addCarry: function () {
    dialog.value.carry = true;
    nextTick(() => {
      carryDialog.value.open();
    });
  },
  editItem: function ({ button }) {
    edit(button.selectRecords[0].main)
  },
};
</script>
